/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "pedido_cab", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PedidoCab.findAll", query = "SELECT p FROM PedidoCab p"),
    @NamedQuery(name = "PedidoCab.findByIdpedidoCab", query = "SELECT p FROM PedidoCab p WHERE p.idpedidoCab = :idpedidoCab"),
    @NamedQuery(name = "PedidoCab.findByFecha", query = "SELECT p FROM PedidoCab p WHERE p.fecha = :fecha")})
public class PedidoCab implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idpedido_cab", nullable = false)
    private Integer idpedidoCab;
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @ManyToMany(mappedBy = "pedidoCabCollection")
    private Collection<OrdenCompraCab> ordenCompraCabCollection;
    @JoinColumn(name = "ci_emp", referencedColumnName = "ci_emp", nullable = false)
    @ManyToOne(optional = false)
    private Empleado ciEmp;
    @JoinColumn(name = "idsucursal", referencedColumnName = "idsucursal", nullable = false)
    @ManyToOne(optional = false)
    private Sucursal idsucursal;
    @JoinColumn(name = "orden_compra", referencedColumnName = "idorden_compra", nullable = false)
    @ManyToOne(optional = false)
    private OrdenCompraCab ordenCompra;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "pedidoCab1")
    private PedidoDet pedidoDet;

    public PedidoCab() {
    }

    public PedidoCab(Integer idpedidoCab) {
        this.idpedidoCab = idpedidoCab;
    }

    public Integer getIdpedidoCab() {
        return idpedidoCab;
    }

    public void setIdpedidoCab(Integer idpedidoCab) {
        this.idpedidoCab = idpedidoCab;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    @XmlTransient
    public Collection<OrdenCompraCab> getOrdenCompraCabCollection() {
        return ordenCompraCabCollection;
    }

    public void setOrdenCompraCabCollection(Collection<OrdenCompraCab> ordenCompraCabCollection) {
        this.ordenCompraCabCollection = ordenCompraCabCollection;
    }

    public Empleado getCiEmp() {
        return ciEmp;
    }

    public void setCiEmp(Empleado ciEmp) {
        this.ciEmp = ciEmp;
    }

    public Sucursal getIdsucursal() {
        return idsucursal;
    }

    public void setIdsucursal(Sucursal idsucursal) {
        this.idsucursal = idsucursal;
    }

    public OrdenCompraCab getOrdenCompra() {
        return ordenCompra;
    }

    public void setOrdenCompra(OrdenCompraCab ordenCompra) {
        this.ordenCompra = ordenCompra;
    }

    public PedidoDet getPedidoDet() {
        return pedidoDet;
    }

    public void setPedidoDet(PedidoDet pedidoDet) {
        this.pedidoDet = pedidoDet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idpedidoCab != null ? idpedidoCab.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PedidoCab)) {
            return false;
        }
        PedidoCab other = (PedidoCab) object;
        if ((this.idpedidoCab == null && other.idpedidoCab != null) || (this.idpedidoCab != null && !this.idpedidoCab.equals(other.idpedidoCab))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.PedidoCab[ idpedidoCab=" + idpedidoCab + " ]";
    }
    
}
